// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;


const int N = 1e5+50;

bool va[N], vb[N];

vector<int> G[N];
int n;

int main(int argc, char const *argv[]) {
    // code
    int t;
    scanf("%d", &t);
    for (int kk=0; kk<t; ++kk) {
        scanf("%d", &n);
        memset(va, 0, sizeof(bool) * (n+1));
        memset(vb, 0, sizeof(bool) * (n+1));
        int ans = 0;
        for (int i=1; i<=n; ++i) {
            int sz;
            scanf("%d", &sz);
            G[i].resize(sz);
            for (int j=0; j<sz; ++j)
                scanf("%d", &G[i][j]);
            for (int j=0; j<sz; ++j) {
                if (!vb[G[i][j]]) {
                    vb[G[i][j]] = va[i] = true;
                    ++ans;
                    break;
                }
            }
        }
        int x = 0, y = 0;
        for (int i=1; i<=n; ++i) {
            if (!va[i]) {
                x = i;
                break;
            }
        }
        for (int i=1; i<=n; ++i) {
            if (!vb[i]) {
                y = i;
                break;
            }
        }
        if (x && y) {
            puts("IMPROVE");
            printf("%d %d\n", x, y);
        } else {
            puts("OPTIMAL");
            // printf("%d\n", ans);
        }
    }
    return 0;
}
